import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.border.LineBorder;
import org.rsbot.util.GlobalConfiguration.Paths;

public class FallenSafeCracker$GUI extends JFrame
  implements WindowListener
{
  private static final long serialVersionUID = -5781125843266714028L;
  private JPanel contentPane;
  private JPanel Panel1;
  private JPanel Panel2;
  private JPanel Panel3;
  private JTabbedPane TabbedPanel;
  private JButton startButton;
  private JButton exitButton;
  private JButton load;
  private JButton save;
  private JRadioButton Box1;
  private JRadioButton Box2;
  private JRadioButton Box3;
  private JRadioButton Box4;
  private JRadioButton Box5;
  private JRadioButton Box6;
  private JRadioButton Box7;
  private JComboBox Options;
  private JLabel OptionText;
  private JLabel BoxText;
  private JLabel FieldText1;
  private JLabel FieldText2;
  private JLabel FieldText3;
  private JFormattedTextField FormTextField1;
  private JFormattedTextField FormTextField2;
  private JFormattedTextField FormTextField3;
  private JFormattedTextField FormTextField4;
  private JFormattedTextField FormTextField5;
  private JTextPane TextPanel;
  FallenSafeCracker script;

  public FallenSafeCracker$GUI(FallenSafeCracker paramFallenSafeCracker1, FallenSafeCracker paramFallenSafeCracker2)
  {
    this.script = paramFallenSafeCracker2;
    initComponents();
  }

  private void initComponents() {
    addWindowListener(this);
    this.contentPane = ((JPanel)getContentPane());
    this.contentPane.setLayout(null);
    this.contentPane.setOpaque(false);

    this.TabbedPanel = new JTabbedPane();
    this.Panel1 = new JPanel();
    this.Panel2 = new JPanel();
    this.Panel3 = new JPanel();
    this.TabbedPanel.setFont(new Font("Verdana", 0, 12));
    this.TabbedPanel.setBorder(null);
    this.TabbedPanel.setFocusable(false);
    this.TabbedPanel.addTab("General", this.Panel1);
    this.TabbedPanel.addTab("Stopping", this.Panel2);
    this.TabbedPanel.addTab("Info", this.Panel3);
    this.Panel1.setFont(new Font("Verdana", 0, 12));
    this.Panel1.setFocusable(false);
    this.Panel1.setLayout(null);
    this.Panel2.setFont(new Font("Verdana", 0, 12));
    this.Panel2.setFocusable(false);
    this.Panel2.setLayout(null);
    this.Panel3.setFont(new Font("Verdana", 0, 12));
    this.Panel3.setFocusable(false);
    this.Panel3.setLayout(null);

    this.startButton = new JButton();
    this.startButton.setFont(new Font("Verdana", 0, 12));
    this.startButton.setText("Start");
    this.startButton.setEnabled(true);
    this.startButton.addActionListener(new FallenSafeCracker.GUI.1(this));

    this.exitButton = new JButton();
    this.exitButton.setText("Cancel");
    this.exitButton.addActionListener(new FallenSafeCracker.GUI.2(this));

    this.load = new JButton();
    this.load.setText("Load");
    this.load.addActionListener(new FallenSafeCracker.GUI.3(this));

    this.save = new JButton();
    this.save.setText("Save");
    this.save.addActionListener(new FallenSafeCracker.GUI.4(this));

    String[] arrayOfString = { "Trout", "Salmon", "Tuna", "Cake", "Lobster", "Bass", "Swordfish", "Monkfish", "Shark", "Rocktail" };

    this.Options = new JComboBox(arrayOfString);
    this.OptionText = new JLabel();
    this.OptionText.setFont(new Font("Verdana", 0, 14));
    this.OptionText.setText("Which food to use?");
    this.Options.setBorder(null);
    this.Options.setOpaque(false);
    this.Options.setFocusable(false);

    this.FormTextField1 = new JFormattedTextField();
    this.FormTextField1.setValue("10");
    this.FormTextField1.setEnabled(true);
    this.BoxText = new JLabel();
    this.BoxText.setText("Amount of food to withdraw:");
    this.BoxText.setEnabled(true);

    this.FieldText1 = new JLabel();
    this.FieldText1.setText("Eat when health drops below: ");
    this.FieldText1.setEnabled(true);
    this.FormTextField2 = new JFormattedTextField();
    this.FormTextField2.setValue("200");
    this.FormTextField2.setEnabled(true);

    this.Box7 = new JRadioButton();
    this.Box7.setText("Use location-switching?");
    this.Box7.setEnabled(true);
    this.Box7.setSelected(false);
    this.Box7.addActionListener(new FallenSafeCracker.GUI.5(this));

    this.Box1 = new JRadioButton();
    this.Box1.setText("Advanced mode");
    if (this.Box7.isSelected())
      this.Box1.setEnabled(true);
    else {
      this.Box1.setEnabled(false);
    }
    this.Box1.setSelected(false);

    this.Box2 = new JRadioButton();
    this.Box2.setText("Use Stethoscope?");
    this.Box2.setEnabled(true);
    this.Box2.setSelected(true);
    this.Box2.addActionListener(new FallenSafeCracker.GUI.6(this));

    this.Box6 = new JRadioButton();
    this.Box6.setText("Click the scope?");
    if (this.Box2.isSelected()) {
      this.Box6.setEnabled(true);
    }
    this.Box6.setSelected(false);

    this.Box3 = new JRadioButton();
    this.Box3.setText("Take a screenshot when finished?");
    this.Box3.setEnabled(true);
    this.Box2.setSelected(true);

    this.Box4 = new JRadioButton();
    this.Box4.setText("Stop after:");
    this.Box4.setEnabled(true);
    this.Box4.setSelected(false);
    this.Box4.addActionListener(new FallenSafeCracker.GUI.7(this));

    this.FieldText2 = new JLabel();
    this.FieldText2.setText("Hours:");
    this.FieldText2.setEnabled(false);
    this.FormTextField3 = new JFormattedTextField();
    this.FormTextField3.setValue("2");
    this.FormTextField3.setEnabled(false);

    this.FieldText3 = new JLabel();
    this.FieldText3.setText("Minutes:");
    this.FieldText3.setEnabled(false);
    this.FormTextField4 = new JFormattedTextField();
    this.FormTextField4.setValue("30");
    this.FormTextField4.setEnabled(false);

    this.Box5 = new JRadioButton();
    this.Box5.setText("Stop when reached level: ");
    this.Box5.setEnabled(true);
    this.Box5.setSelected(false);
    this.Box5.addActionListener(new FallenSafeCracker.GUI.8(this));

    this.FormTextField5 = new JFormattedTextField();
    this.FormTextField5.setValue("99");
    this.FormTextField5.setEnabled(false);

    this.TextPanel = new JTextPane();
    this.TextPanel.setText("Fallen's SafeCracker v4.3\n\n Start the script at Rogue Den's. Have food visible in your bank.\n\n Advanced location switching will wait 1-3 minutes to check if the player beneath us moves until switching location.");

    this.TextPanel.setEditable(false);
    this.TextPanel.setFont(new Font("Verdana", 0, 12));
    this.TextPanel.setBorder(new LineBorder(Color.black));

    setSize(400, 400);
    setTitle("Fallen's SafeCracker v4.3");
    addComponent(this.contentPane, this.startButton, 5, 270, 375, 55);
    addComponent(this.contentPane, this.exitButton, 140, 330, 100, 26);
    addComponent(this.contentPane, this.TabbedPanel, 5, 5, 375, 260);
    addComponent(this.contentPane, this.save, 5, 333, 60, 20);
    addComponent(this.contentPane, this.load, 315, 333, 60, 20);

    addComponent(this.Panel1, this.OptionText, 113, 10, 250, 25);
    addComponent(this.Panel1, this.Options, 145, 37, 80, 20);
    addComponent(this.Panel1, this.BoxText, 5, 70, 159, 20);
    addComponent(this.Panel1, this.FormTextField1, 180, 70, 50, 20);
    addComponent(this.Panel1, this.FieldText1, 5, 100, 170, 20);
    addComponent(this.Panel1, this.FormTextField2, 180, 100, 50, 20);
    addComponent(this.Panel1, this.Box7, 5, 130, 290, 20);
    addComponent(this.Panel1, this.Box1, 50, 150, 290, 20);
    addComponent(this.Panel1, this.Box3, 5, 170, 230, 20);
    addComponent(this.Panel1, this.Box2, 5, 190, 200, 20);
    addComponent(this.Panel1, this.Box6, 50, 210, 200, 20);

    addComponent(this.Panel2, this.Box4, 5, 60, 100, 20);
    addComponent(this.Panel2, this.FieldText2, 140, 60, 40, 20);
    addComponent(this.Panel2, this.FormTextField3, 179, 60, 30, 20);
    addComponent(this.Panel2, this.FieldText3, 230, 60, 50, 20);
    addComponent(this.Panel2, this.FormTextField4, 280, 60, 30, 20);
    addComponent(this.Panel2, this.Box5, 5, 150, 170, 20);
    addComponent(this.Panel2, this.FormTextField5, 179, 150, 30, 20);
    addComponent(this.Panel3, this.TextPanel, 10, 10, 350, 210);
  }

  private void addComponent(Container paramContainer, Component paramComponent, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    paramComponent.setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
    paramContainer.add(paramComponent);
  }

  private void startButtonActionPerformed()
  {
    FallenSafeCracker.access$1802(this.this$0, this.Options.getSelectedItem().toString());
    FallenSafeCracker.access$1902(this.this$0, this.FormTextField1.getValue());
    FallenSafeCracker.access$2002(this.this$0, this.FormTextField2.getValue());

    FallenSafeCracker.access$2102(this.this$0, this.FormTextField3.getValue());
    FallenSafeCracker.access$2202(this.this$0, this.FormTextField4.getValue());

    FallenSafeCracker.access$2302(this.this$0, this.FormTextField5.getValue());

    if (FallenSafeCracker.access$1800(this.this$0).equals("Trout")) {
      FallenSafeCracker.access$2402(this.this$0, 333);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Salmon")) {
      FallenSafeCracker.access$2402(this.this$0, 329);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Tuna")) {
      FallenSafeCracker.access$2402(this.this$0, 361);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Cake")) {
      FallenSafeCracker.access$2402(this.this$0, 1891);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Lobster")) {
      FallenSafeCracker.access$2402(this.this$0, 379);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Bass")) {
      FallenSafeCracker.access$2402(this.this$0, 365);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Swordfish")) {
      FallenSafeCracker.access$2402(this.this$0, 373);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Monkfish")) {
      FallenSafeCracker.access$2402(this.this$0, 7946);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Shark")) {
      FallenSafeCracker.access$2402(this.this$0, 385);
    }
    if (FallenSafeCracker.access$1800(this.this$0).equals("Rocktail")) {
      FallenSafeCracker.access$2402(this.this$0, 15272);
    }
    FallenSafeCracker.access$2502(Integer.parseInt((String)FallenSafeCracker.access$1900(this.this$0)));

    FallenSafeCracker.access$2602(Integer.parseInt((String)FallenSafeCracker.access$2000(this.this$0)));

    if (this.Box7.isSelected()) {
      FallenSafeCracker.access$2702(this.this$0, true);
      if (this.Box1.isSelected())
        FallenSafeCracker.access$2802(this.this$0, true);
      else
        FallenSafeCracker.access$2802(this.this$0, false);
    }
    else {
      FallenSafeCracker.access$2702(this.this$0, false);
      FallenSafeCracker.access$2802(this.this$0, false);
    }
    if (this.Box2.isSelected())
      FallenSafeCracker.access$2902(this.this$0, true);
    else {
      FallenSafeCracker.access$2902(this.this$0, false);
    }
    if (this.Box3.isSelected()) {
      FallenSafeCracker.access$3002(this.this$0, true);
    }
    if (this.Box4.isSelected()) {
      FallenSafeCracker.access$3102(this.this$0, true);
      FallenSafeCracker.access$3202(Integer.parseInt((String)FallenSafeCracker.access$2100(this.this$0)));

      FallenSafeCracker.access$3302(Integer.parseInt((String)FallenSafeCracker.access$2200(this.this$0)));
    }

    if (this.Box5.isSelected()) {
      FallenSafeCracker.access$3402(this.this$0, true);
      FallenSafeCracker.access$3502(Integer.parseInt((String)FallenSafeCracker.access$2300(this.this$0)));
    }

    if ((this.Box6.isSelected()) && (this.Box6.isEnabled())) {
      FallenSafeCracker.access$3602(this.this$0, true);
    }

    this.script.WaitForStart = false;
    FallenSafeCracker.access$3702(this.this$0, true);
    dispose();
  }

  private void Box4ButtonActionPerformed()
  {
    if (this.Box4.isSelected()) {
      this.Box5.setSelected(false);

      this.FieldText2.setEnabled(true);
      this.FormTextField3.setEnabled(true);
      this.FieldText3.setEnabled(true);
      this.FormTextField4.setEnabled(true);

      this.FormTextField5.setEnabled(false);
    } else if (!this.Box5.isSelected())
    {
      this.Box4.setSelected(false);
      this.Box5.setSelected(false);
      this.Box4.setSelected(false);
      this.Box5.setSelected(false);
      this.FieldText2.setEnabled(false);
      this.FormTextField3.setEnabled(false);
      this.FieldText3.setEnabled(false);
      this.FormTextField4.setEnabled(false);
      this.FormTextField5.setEnabled(false);
    }
  }

  private void Box5ButtonActionPerformed() {
    if (this.Box5.isSelected()) {
      this.Box4.setSelected(false);

      this.FieldText2.setEnabled(false);
      this.FormTextField3.setEnabled(false);
      this.FieldText3.setEnabled(false);
      this.FormTextField4.setEnabled(false);

      this.FormTextField5.setEnabled(true);
    } else if (!this.Box4.isSelected())
    {
      this.Box4.setSelected(false);
      this.Box5.setSelected(false);
      this.FieldText2.setEnabled(false);
      this.FormTextField3.setEnabled(false);
      this.FieldText3.setEnabled(false);
      this.FormTextField4.setEnabled(false);
      this.FormTextField5.setEnabled(false);
    }
  }

  private void exitButtonActionPerformed() {
    this.this$0.WaitForStart = false;
    FallenSafeCracker.access$3702(this.this$0, false);
    dispose();
  }

  public void windowClosing(WindowEvent paramWindowEvent)
  {
    this.this$0.WaitForStart = false;
    FallenSafeCracker.access$3702(this.this$0, false);
    dispose();
  }

  public void windowActivated(WindowEvent paramWindowEvent)
  {
    toFront();
  }

  public void windowClosed(WindowEvent paramWindowEvent)
  {
  }

  public void windowDeactivated(WindowEvent paramWindowEvent)
  {
  }

  public void windowDeiconified(WindowEvent paramWindowEvent)
  {
  }

  public void windowIconified(WindowEvent paramWindowEvent)
  {
  }

  public void windowOpened(WindowEvent paramWindowEvent) {
  }

  private boolean saveOptions(Properties paramProperties) {
    String str1 = this.Options.getSelectedItem().toString();
    paramProperties.setProperty("Food", str1);
    String str2;
    try {
      str2 = this.FormTextField1.getValue().toString();
    } catch (Exception localException1) {
      str2 = "10";
    }paramProperties.setProperty("WDAM", str2);
    String str3;
    try {
      str3 = this.FormTextField2.getValue().toString();
    } catch (Exception localException2) {
      str3 = "200";
    }
    paramProperties.setProperty("EatLimit", str3);

    if (this.Box7.isSelected()) {
      paramProperties.setProperty("Change", "1");
      if (this.Box1.isSelected())
        paramProperties.setProperty("Advanced", "1");
      else
        paramProperties.setProperty("Advanced", "2");
    }
    else {
      paramProperties.setProperty("Change", "2");
      paramProperties.setProperty("Advanced", "2");
    }

    if (this.Box3.isSelected())
      paramProperties.setProperty("ScreenShot", "1");
    else {
      paramProperties.setProperty("ScreenShot", "2");
    }

    if (this.Box2.isSelected())
      paramProperties.setProperty("Stethoscope", "1");
    else {
      paramProperties.setProperty("Stethoscope", "2");
    }

    if (this.Box6.isSelected())
      paramProperties.setProperty("ClickFirst", "1");
    else {
      paramProperties.setProperty("ClickFirst", "2");
    }

    String str4 = "2";
    String str5 = "30";
    if (this.Box4.isSelected()) {
      paramProperties.setProperty("TimeLimit", "1");
      try {
        str4 = (String)this.FormTextField3.getValue();
        str5 = (String)this.FormTextField4.getValue();
      } catch (Exception localException3) {
        str4 = "2";
        str5 = "30";
      }
    } else {
      paramProperties.setProperty("TimeLimit", "2");
    }
    paramProperties.setProperty("Hours", str4);
    paramProperties.setProperty("Minutes", str5);

    String str6 = "99";
    if (this.Box5.isSelected()) {
      paramProperties.setProperty("LevelLimit", "1");
      try {
        str6 = (String)this.FormTextField5.getValue();
      } catch (Exception localException4) {
        str6 = "99";
      }
    } else {
      paramProperties.setProperty("LevelLimit", "2");
    }
    paramProperties.setProperty("Level", str6);
    try
    {
      paramProperties.store(new FileWriter(new File(GlobalConfiguration.Paths.getSettingsDirectory(), "FallenSafeCracker.ini")), "The options of FallenSafeCracker");

      return true; } catch (IOException localIOException) {
    }
    return false;
  }

  private boolean loadOptions(Properties paramProperties)
  {
    try {
      paramProperties.load(new FileInputStream(new File(GlobalConfiguration.Paths.getSettingsDirectory(), "FallenSafeCracker.ini")));
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      return false;
    } catch (IOException localIOException) {
      return false;
    }

    if (paramProperties.getProperty("Food") != null) {
      this.Options.setSelectedItem(paramProperties.getProperty("Food"));
    }
    if (paramProperties.getProperty("WDAM") != null) {
      this.FormTextField1.setValue(paramProperties.getProperty("WDAM"));
    }
    if (paramProperties.getProperty("EatLimit") != null) {
      this.FormTextField2.setValue(paramProperties.getProperty("EatLimit"));
    }
    if (paramProperties.getProperty("Change") != null) {
      if (paramProperties.getProperty("Change").equals("1")) {
        this.Box7.setSelected(true);
        this.Box1.setEnabled(true);
        if (paramProperties.getProperty("Advanced") != null)
          if (paramProperties.getProperty("Advanced").equals("1"))
            this.Box1.setSelected(true);
          else
            this.Box1.setSelected(false);
      }
      else
      {
        this.Box1.setEnabled(false);
        this.Box7.setSelected(false);
        this.Box1.setSelected(false);
      }
    }
    if (paramProperties.getProperty("ScreenShot") != null) {
      if (paramProperties.getProperty("ScreenShot").equals("1"))
        this.Box3.setSelected(true);
      else {
        this.Box3.setSelected(false);
      }
    }
    if (paramProperties.getProperty("Stethoscope") != null) {
      if (paramProperties.getProperty("Stethoscope").equals("1")) {
        this.Box2.setSelected(true);
        this.Box6.setEnabled(true);
      } else {
        this.Box2.setSelected(false);
        this.Box6.setSelected(false);
        this.Box6.setEnabled(false);
      }
    }
    if (paramProperties.getProperty("ClickFirst") != null) {
      if (paramProperties.getProperty("ClickFirst").equals("1"))
        this.Box6.setSelected(true);
      else {
        this.Box6.setSelected(false);
      }
    }
    if (paramProperties.getProperty("TimeLimit") != null) {
      if (paramProperties.getProperty("TimeLimit").equals("1")) {
        this.Box4.setSelected(true);
        this.Box5.setSelected(false);
        this.FieldText2.setEnabled(true);
        this.FormTextField3.setEnabled(true);
        this.FieldText3.setEnabled(true);
        this.FormTextField4.setEnabled(true);

        this.FormTextField5.setEnabled(false);
        if (paramProperties.getProperty("Hours") != null) {
          this.FormTextField3.setValue(paramProperties.getProperty("Hours"));
        }
        if (paramProperties.getProperty("Minutes") != null)
          this.FormTextField4.setValue(paramProperties.getProperty("Minutes"));
      }
      else {
        this.Box4.setSelected(false);
        this.Box5.setSelected(true);
      }
    }
    if (paramProperties.getProperty("LevelLimit") != null) {
      if (paramProperties.getProperty("LevelLimit").equals("1")) {
        this.Box4.setSelected(false);
        this.Box5.setSelected(true);
        this.FieldText2.setEnabled(false);
        this.FormTextField3.setEnabled(false);
        this.FieldText3.setEnabled(false);
        this.FormTextField4.setEnabled(false);

        this.FormTextField5.setEnabled(true);
        if (paramProperties.getProperty("Level") != null)
          this.FormTextField5.setValue(paramProperties.getProperty("Level"));
      }
      else {
        this.Box4.setSelected(true);
        this.Box5.setSelected(false);
      }
    }
    return true;
  }
}